﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;

namespace BLL
{
    public class ClsDVHanhNgheKhoanGiengBus
    {
        public ClsDMDVHanhNgheKhoanGiengInfo Info = new ClsDMDVHanhNgheKhoanGiengInfo();
        public DataTable SelectAll()
        {
            ClsDataAccess oConnection = new ClsDataAccess();
            string strSql = @"SELECT * FROM DVHanhNgheKhoanGieng";

            if (oConnection.ExecuteSelect(strSql))
            {
                oConnection.ODataTable.Columns.Add("STT");
                int i = 0;
                foreach (DataRow oDRow in oConnection.ODataTable.Rows)
                {
                    oDRow["STT"] = (i + 1);
                    i++;
                }
                return oConnection.ODataTable;
            }
            else return null;
        }
        public bool Them()
        {
            string strSql = "EXECUTE InsertDVHanhNgheKhoanGieng '" + Info.MaDV + "', N'" + Info.TenDV + "', N'" + Info.DiaChi + "', N'" + Info.GiayPhep + "', N'" + Info.DVGiayPhep + "','"+Info.Tinh+"'";
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));
        }

        public bool Sua()
        {
            string strSql = "EXECUTE UpdateDVHanhNgheKhoanGieng'" + Info.MaDV + "', N'" + Info.TenDV + "', N'" + Info.DiaChi + "', N'" + Info.GiayPhep + "', N'" + Info.DVGiayPhep +"','"+Info.Tinh+ "'";
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));
        }

        public bool Xoa()
        {
            string strSql = "EXECUTE DeleteDVHanhNgheKhoanGieng'" + Info.MaDV + "'";
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));

        }


    }
}
